package com.cn.wanxi.servlet;

import com.cn.wanxi.service.CompanyService;
import com.cn.wanxi.service.CompanyThreeService;
import com.cn.wanxi.service.ICompanyService;
import com.cn.wanxi.service.NavService;

import javax.servlet.http.HttpServletRequest;

/**
 * 不是页面控制层
 */
class TopAndFootServlet {
    static void getData(HttpServletRequest req) {
//        ICompany companyService = new CompanyService();
//        CompanyThreeService threeService = new CompanyThreeService();
        ICompanyService iCompanyService = new CompanyThreeService();
//        接口
        String path = req.getServletContext().getRealPath("/");
//        E:\wanxi\step-3\canyin03-0823\out\artifacts\canyin03_0823_war_exploded\
//        需要对字符串进行截取
//        path = path.substring(3, 5);
        String[] split = path.split("out");
        req.setAttribute("companyModel", iCompanyService.getCompanyModel(split[0]));
        req.setAttribute("navModels", new NavService().getNavModels());
    }

    public static void main(String[] args) {
        String path = "E:\\wanxi\\step-3\\canyin03-0823\\out\\artifacts\\canyin03_0823_war_exploded\\";
//        String substring = path.substring(0, 5);
//        将path转变为数组：
//       字符串转变为数组
        String aa = "out";//不属于正则表达式的格式
        String[] split = path.split(aa);
        System.out.println(split[0]);

    }
}
